#define DDCL_CORE

#include "ddclerr.h"

static const struct {
    int e;
    const char * str;
}_STRS[] = {
    { DDCL_OK , "ok" },
    { DDCL_FILE_PATH_ERR, "File path is error" },
    { DDCL_FILE_NOT_EXIST, "File is not exist" },
    { DDCL_FILE_MUST_BE_DIR, "File path must be directory" },
    { DDCL_FILE_CANNOT_BE_DIR, "File path can not be directory" },

    { DDCL_MODULE_NOT_EXIST, "module not exist" },
    { DDCL_MODULE_NOT_OPENED, "module not opened" },
    { DDCL_DEPEND_MODULE_NOT_OPENED, "depend module not opened" },

    { DDCL_SERVICE_UNKNOW_HANDLE, "Unknow service handle" },
    { DDCL_SERVICE_THREAD_IS_REGISTERED, "Thread has been registered in service framework" },

    { DDCL_SOCKET_INVALID_HANDLE, "Unknow socket handle" },

    { DDCL_ERR_END, "Unknow error" },
    { -1, "system error"},
};


DDCLAPI const char *
ddcl_err(int err){
    int i = 0;
    for(;;){
        int e = _STRS[i].e;
        if(e != -1 && err == e){
            return _STRS[i].str;
        }else if(e == -1){
            return _STRS[i - 1].str;
        }
        i ++;
    }
    return NULL;
}

